#include <stdio.h>
#include <string.h>
void swp(char* p1, char* p2, int width)
{
    char ch = 0;
    for (int i = 0; i < width; i++)
    {
        char x = *((char*)p1);
        *((char*)p1) = *((char*)p2);
        *((char*)p2) = x;
        p1++;
        p2++;
    }
}
int charge(void* s1, void* s2)
{
    return strcmp((char*)s1,(char*)s2);
}
void bubble_sort(void* str,int n,int sz,int(*charge)(void* s1,void* s2))
{
    
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = 0; j < n -i- 1; j++)
        {
            if (charge((char*)str+sz*j,(char*)str+sz*(j+1))>0)
            {
                swp((char*)str + sz * j, (char*)str + sz * (j + 1), sz);
            }
        }
    }
}


int main()
{
    char arr[] = "edcba";
    int n = sizeof(arr) / sizeof(arr[0]);

    bubble_sort(arr,n, sizeof(arr[0]), charge);
    for (int i = 0; i < n; i++)
    {
        printf("%c ", arr[i]);
    }
    return 0;
}